package com.sd365.permission.centre.api;

import com.sd365.common.core.annotation.stuffer.CommonFieldStuffer;
import com.sd365.common.core.annotation.stuffer.MethodTypeEnum;
import com.sd365.permission.centre.pojo.dto.CompanyDTO;
import com.sd365.permission.centre.pojo.query.IdVersionQuery;
import com.sd365.permission.centre.pojo.dto.DepartmentDTO;
import com.sd365.permission.centre.pojo.query.DepartmentQuery;
import com.sd365.permission.centre.pojo.vo.CompanyVO;
import com.sd365.permission.centre.pojo.vo.DepartmentVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @Author jxd
 * @Date 2020/12/12  1:12 下午
 * @Version 1.0
 * @Write For DepartmentApi
 * @Email waniiu@126.com
 */
@CrossOrigin
@Api(tags = "部门 管理 ",value ="/permission/centre/v1/department")
@RequestMapping(value = "/permission/centre/v1/department")
public interface DepartmentApi {

    /**
     * 通用查询
     * @param departmentQuery
     * @return
     */
    @ApiOperation(tags = "查询部门信息，分页", value = "")
    @GetMapping("")
    @ResponseBody
    @CommonFieldStuffer(methodType = MethodTypeEnum.QUERY)
    List<DepartmentVO> commonQueryDepartment(DepartmentQuery departmentQuery);
//    List<DepartmentVO> commonQueryDepartment(@RequestBody(required=false) DepartmentQuery departmentQuery);

    /**
     * @Title:
     * @Description: 批量更新
     * @Date: 20:36 2020/12/15
     * @return:
     **/
    @ApiOperation(tags="批量更新",value="/batch")
    @PutMapping(value = "/batch")
    @ResponseBody
    @CommonFieldStuffer(methodType = MethodTypeEnum.UPDATE)
    Boolean batchUpdate(@RequestBody List<DepartmentDTO> departmentDTOS);


    @ApiOperation(tags = "部门查询", value = "departmentQuery")
    @GetMapping(value = "departmentQuery")
    @ResponseBody
    List<DepartmentVO> commonQuery(@ApiParam @Valid DepartmentQuery departmentQuery);

    @ApiOperation(tags = "部门添加", value = "departmentAdd")
    @PostMapping(value = "departmentAdd")
    @ResponseBody
    Boolean add(@ApiParam @RequestBody @Valid DepartmentDTO dto);



    @ApiOperation(tags = "部门修改", value = "departmentUpdate")
    @PutMapping(value = "departmentUpdate")
    @ResponseBody
    Boolean update(@Valid @RequestBody DepartmentDTO dto);

    @ApiOperation(tags = "查询department通过ID", value = "/{id}")
    @GetMapping(value = "/{id}")
    @ResponseBody
    DepartmentVO queryDepartmentById(@PathVariable("id") Long id);

    @ApiOperation(tags = "根据name删除单条数据", value = "departmentDelete")
    @DeleteMapping(value = "departmentDelete")
    @ResponseBody
    Boolean deleteOneById(@ApiParam(value = "当前行id", required = true) @RequestParam("id") Long id,
                          @ApiParam(value = "当前发行版本", required = true) @RequestParam("version") Long version);

    @ApiOperation(tags = "根据name删除多条数据", value = "/deleteBatch")
    @DeleteMapping(value = "/deleteBatch")
    @ResponseBody
    Boolean deleteBatch(@RequestBody List<IdVersionQuery> batchQuery);


    @ApiOperation(tags = "拷贝部门", value = "/copy")
    @PostMapping(value = "/copy")
    @ResponseBody
    DepartmentDTO copy(Long id);

    @ApiOperation(tags = "通过id查询", value = "/status")
    @PutMapping(value = "/status")
    @ResponseBody
    public Boolean status(@RequestBody DepartmentDTO departmentDTO);


    @ApiOperation(tags = "构建部门资源树", value = "/status")
    @GetMapping(value = "/deptree")
    @ResponseBody
    List<DepartmentDTO> builderTree( DepartmentQuery departmentQuery);
}
